import React from "react";
import classNames from "classnames";
/**
 * ~~~js
 * 默认二封增强树组件
 * ~~~~
 */
export default function DevToolBarDefaultHoc(WrappedComponent) {
    // 泛型限定
    return class extends WrappedComponent {
        parent = super.render();
        defaultConfig = {};
        toolBarRef;
        get tooBarInstance() {
            return this.toolBarRef.current.instance;
        }
        constructor(...props) {
            super(...props);
            this.toolBarRef = React.createRef();
        }
        componentDidMount() { }
        componentWillUnmount() {
            console.log("卸载事件");
            this.tooBarInstance.dispose();
        }
        render() {
            const klass = classNames("cpas-tool-bar");
            const { ...rest } = this.props;
            let props = {
                className: klass,
                ...this.defaultConfig,
                ...rest,
                ref: this.toolBarRef,
            };
            return React.cloneElement(this.parent, { ...props });
        }
    };
}
